<template>
    <div class="content" ref="content">
        <div class="storey" ref="storey">

        </div>
        <div class="card" @click.stop="handleClickGrid">
            <div class="card_input" @click.stop="handleClickPath(1)" ref="path1">
                <div class="card_input_inner"></div>
            </div>
            <div class="card_select">
                <div class="card_select_left" @click.stop="handleClickPath(2)" ref="path2">
                    <div class="card_select_left_inner"></div>
                </div>
                <div class="card_select_right" @click.stop="handleClickPath(3)" ref="path3">
                    <div class="card_select_right_inner"></div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
let path1 = ref();
let path2 = ref();
let path3 = ref();
let content = ref();
let storey = ref();
const handleClickPath = (path) => {
    let contentRect = content.value.getBoundingClientRect();
    let difFatherOffset = {
        x: contentRect.x,
        y: contentRect.y
    }
    let pathRectMap = {
        '1': path1.value.getBoundingClientRect(),
        '2': path2.value.getBoundingClientRect(),
        '3': path3.value.getBoundingClientRect(),
    }
    let PathRect = pathRectMap[path];

    let clickDomOffset = {
        x: PathRect.x - difFatherOffset.x,
        y: PathRect.y - difFatherOffset.y,
    }
    storey.value.style.zIndex = 99;
    storey.value.style.opacity = 1;
    storey.value.style.width = PathRect.width + 'px';
    storey.value.style.height = PathRect.height + 'px';
    storey.value.style.left = clickDomOffset.x + 'px';
    storey.value.style.top = clickDomOffset.y + 'px';
}
const handleClickGrid = () => {
    storey.value.style.zIndex = -1;
    storey.value.style.opacity = .1;
    storey.value.style.width = '100%';
    storey.value.style.height = '100%';
    storey.value.style.left = '0px';
    storey.value.style.top = '0px';
}
</script>

<style lang="less" scoped>
.content {
    width: 430px;
    height: 270px;
    border-radius: 10px;
    box-shadow: 0px 0px 10px skyblue;
    background-color: white;
    box-sizing: border-box;
    padding: 20px;
    position: relative;
    margin-top: 100px;
    margin-left: 100px;
}

.storey {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background-color: rgba(0, 0, 0, .2);
    border: 2px solid #fff;
    z-index: -1;
    left: 0px;
    top: 0px;
    box-sizing: border-box;
    transition: all .35s cubic-bezier(.71, .03, .56, .85);
}

.card {
    width: 100%;
    height: 100%;
    padding-top: 50px;

    .card_input {
        width: 100%;
        height: 48px;
        cursor: pointer;
        padding: 4px;

        .card_input_inner {
            width: 100%;
            height: 100%;
            border-radius: 10px;
            background: rgba(135, 207, 235, 0.281);
        }
    }

    .card_select {
        display: flex;
        margin-top: 40px;

        .card_select_left {
            width: 78%;
            height: 48px;
            cursor: pointer;
            padding: 4px;

            .card_select_left_inner {
                background: rgba(135, 207, 235, 0.281);
                border-radius: 10px;
                width: 100%;
                height: 100%;
            }
        }

        .card_select_right {
            cursor: pointer;
            height: 48px;
            flex: 1;
            margin-left: 10px;
            padding: 4px;

            .card_select_right_inner {
                background: rgba(135, 207, 235, 0.281);
                border-radius: 10px;
                width: 100%;
                height: 100%;
            }
        }
    }
}
</style>